package com.sunshine.wrongquestionset.room.entity

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import java.util.*

/**
 * @author sunshine
 * @date 2021/4/11
 * 问题的信息，存储一个问题的信息，对后期数据分析有很大的帮助
 * 每次进入软件都会对这个表进行更新
 */
@Entity(
    tableName = "question_info",
    foreignKeys = [
        ForeignKey(
            entity = QuestionEntity::class,
            parentColumns = ["id"],
            childColumns = ["questionId"],
            onUpdate = ForeignKey.CASCADE,
            onDelete = ForeignKey.CASCADE
        )
    ],
    indices = [
        Index("questionId")
    ]
)
class QuestionInfoEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Int,
    val questionId: Int,
    val familiarity: Float,

    //2021 04 12 新增 时间列，用于后期统计
    val time: Long = Date().time
) {
    override fun toString(): String {
        return "QuestionInfoEntity(id=$id, questionId=$questionId, familiarity=$familiarity, time=$time)"
    }
}